/**
 * Copyright (c) 2018-2023, NXOS Development Team
 * SPDX-License-Identifier: Apache-2.0
 *
 * Contains: VirtIO over MMIO Bus Interface
 *
 * Change Logs:
 * Date           Author            Notes
 * 2023-07-18     Shiroko           Init
 */


#ifndef __DRIVERS_VIRTIO_VIRTIO_MMIO_H__
#define __DRIVERS_VIRTIO_VIRTIO_MMIO_H__

#include <nxos.h>

/* VIRTIO MMIO Interface */

struct VirtioMMIODeviceInfo
{
    NX_Addr phyAddr;
    NX_Size memSize;
    NX_U32  interrupt;
    NX_U32  interruptParent;
};
typedef struct VirtioMMIODeviceInfo VirtioMMIODeviceInfo;

/* MMIO Setup & Clean Up */
NX_Error VirtioMMIOSetup(VirtioDriverTableEntity **driversTable);
void VirtioMMIOCleanUpDevice(NX_Device *device);
NX_Error VirtioMMIORegisterDevice(VirtioMMIODeviceInfo *info); // Info should be freed after call.
/* MMIO Common Cfg */
void VirtioMMIOCommonConfigGet(NX_Device *device, VirtioCommonConfigItem item, void *value);
void VirtioMMIOCommonConfigSet(NX_Device *device, VirtioCommonConfigItem item, void *value);
/* MMIO Device Cfg */
void *VirtioMMIOGetDeviceConfig(NX_Device *device);
/* MMIO Send Available Notification */
void VirtioMMIOSendNotification(NX_Device *device, NX_U16 queue_index);

#endif // __DRIVERS_VIRTIO_VIRTIO_MMIO_H__